/**
 * Created by dukes on 2016/1/30.
 */
class MengRulePanel extends eui.Component{
    public constructor(){
        super();
        this.skinName = "pet.MengRuleSkin";
    }
    private img_close:eui.Image;
    public partAdded(name:string, instance:any) {
        super.partAdded(name, instance);
        if (name == "img_close") {
            this.img_close = instance;
            this.img_close.addEventListener(egret.TouchEvent.TOUCH_TAP, this.onClose, this);
        }
    }

    private onClose(evt:egret.TouchEvent){
        SoundMgr.getInstance().playEffect(SoundMgr.BTN);
        DisplayController.instance().removeFromAlert(GameConst.GrayMask);
        DisplayController.instance().removeFromAlert(this);
    }


    public show(){
        if( !DisplayController.instance().stage) return;
        DisplayController.instance().addToAlert(GameConst.GrayMask);
        DisplayController.instance().addToAlert(this);
    }

    public measure() {
        super.measure();
        this.x = GameConst.StageW - this.measuredWidth >> 1;
        this.y = GameConst.StageH - this.measuredHeight >> 1;
    }
    private static _instance:MengRulePanel;
    public static getInstance():MengRulePanel{
        if( MengRulePanel._instance == null )
            MengRulePanel._instance = new MengRulePanel();
        return MengRulePanel._instance;
    }
}